<?php include 'head.php'; ?>
    <title>登录记录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/component/pear/css/pear.css" />
</head>

<body class="pear-container">
    <div class="layui-card">
        <div class="layui-card-header">登录记录</div>
        <div class="layui-card-body">
            <table id="log" lay-filter="log"></table>
        </div>
    </div>
    
    <script type="text/html" id="log-toolbar">
    </script>

</body>
<script src="/component/layui/layui.js"></script>

<script src="/component/pear/pear.js"></script>
<script>
    layui.use(['layer', 'element', 'popup', 'table'], function() {
        var $ = layui.jquery,
            layer = layui.layer,
            element = layui.element,
            popup = layui.popup,
            table = layui.table;

        table.render({
            elem: '#log',
            height: 500,
            url: './ajax.php?act=getlog',
            page: true,
            escape: true,
            toolbar: '#log-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports'],
            cols: [
                [{
                        field: 'id',
                        title: 'ID',
                        width: 80,
                        sort: true,
                        fixed: 'left'
                    }, {
                        field: 'msg',
                        title: '信息',
                    }, {
                        field: 'ip',
                        title: 'IP地址',
                        sort: true,
                    }, {
                        field: 'name',
                        title: '用户名',
                        sort: true,
                    }, {
                        field: 'time',
                        title: '登录时间',
                        sort: true,
                        width: 200,
                    }
                ]
            ]
        });

        table.on('toolbar(log)', function(obj) {
            if (obj.event === 'refresh') {
                table.reload('log');
            }
        });

    });
</script>

</html>